package com.heifeng.cloudshelf.mvp.search.activity;

import android.content.Context;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;
import android.util.Log;
import android.view.View;

import com.heifeng.cloudshelf.R;
import com.heifeng.cloudshelf.base.BaseActivity;
import com.heifeng.cloudshelf.event.NoSearchDataEvent;
import com.heifeng.cloudshelf.event.SreachNoDataEvent;
import com.heifeng.cloudshelf.mvp.search.contract.SearchNoDataActivityContract;
import com.heifeng.cloudshelf.mvp.search.presenter.SearchNoDataActivityPresenter;
import com.heifeng.cloudshelf.utils.IntentUtil;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import butterknife.BindView;
import butterknife.OnClick;

/*
*搜搜我家  无数据
 */
public class SearchNoDataActivity extends BaseActivity<SearchNoDataActivityPresenter> implements SearchNoDataActivityContract.View {

    @BindView(R.id.recyclerview)
    RecyclerView recyclerView;

    public static void open(Context context) {
        IntentUtil.startActivity(context, SearchNoDataActivity.class);
    }

    @Override
    protected int getLayout() {
        return R.layout.activity_search_no_data;
    }

    @Override
    protected void initEventAndData() {
        EventBus.getDefault().register(this);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }

    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void OpenDetailEvent(NoSearchDataEvent event) {
        Log.e("NoSearchDataEvent", "event:" + event.getData());
//        List<SearchDefaultBean> data = event.getData();
        mPresenter.init(event.getData());
        EventBus.getDefault().removeStickyEvent(event);
    }

    @Override
    protected void initInject() {
        getActivityComponent().inject(this);
    }

    @Override
    public RecyclerView getRecyclerView() {
        return recyclerView;
    }

    @OnClick({R.id.l_back})
    public void Onclick(View view) {
        switch (view.getId()) {
            case R.id.l_back:
                EventBus.getDefault().post(new SreachNoDataEvent());
                finish();
                break;
        }
    }
}
